package one.stand.enums;

import org.apache.commons.lang3.StringUtils;

import java.util.Map;

/**
 * @author: QIK
 * @CreateDate: 2019/4/4 11:43
 */
public enum LoginEnum {
    USER("user", "用户端登陆", 1, false, false, true, StringUtils.EMPTY),
    WX_PAY("wxpay", "微信支付", 4, false, false, true, StringUtils.EMPTY),

    CRM("crm", "crmApp登陆", 2, false, false, true, StringUtils.EMPTY),
    JXS_APP("jxs_app", "经销商App登录", 9, false, false, true, "-1"),

    CRM_PC("CRM_PC", "crmPC端", 3, false, true, true, StringUtils.EMPTY),
    CRM_PC_ADMIN("CRM_PC_ADMIN", "crmPC端-总后台登录", 3, false, true, false, StringUtils.EMPTY),

    ADMIN("admin", "总后台登录", 5, false, false, true, StringUtils.EMPTY),

    IPAD("ipad", "IPAD登录", 6, true, true, true, StringUtils.EMPTY),

    GZH("gzh", "微信公众号登录", 7, false, false, true, StringUtils.EMPTY),
    H5_LEAD("h5_lead", "头条文章登录", 7, false, false, true, StringUtils.EMPTY),
    HMHD_GZH("hmhd_gzh", "红木互动公众号", 11, false, false, true, StringUtils.EMPTY),

    SHOWROOM_ANDROID("showroom_android", "智慧展厅安卓端登录", 8, true, true, false, StringUtils.EMPTY),
    SHOWROOM_WINDOWS("showroom_windows", "智慧展厅Windows端登录", 8, true, true, false, StringUtils.EMPTY),
    ;

    private String code;
    private String message;
    private Integer accountType;
    private boolean checkEquCode;
    private boolean checkCard;
    /**
     * 登录
     */
    private boolean loginSingle;
    private String pushFlag;

    LoginEnum(String code, String message, Integer accountType, boolean checkEquCode, boolean checkCard, boolean loginSingle, String pushFlag) {
        this.code = code;
        this.message = message;
        this.accountType = accountType;
        this.checkEquCode = checkEquCode;
        this.checkCard = checkCard;
        this.loginSingle = loginSingle;
        this.pushFlag = pushFlag;
    }

    public Integer getAccountType() {
        return accountType;
    }

    public String getCode() {
        return code;
    }

    public boolean isCheckEquCode() {
        return checkEquCode;
    }

    public boolean isCheckCard() {
        return checkCard;
    }

    public boolean isLoginSingle() {
        return loginSingle;
    }

    public String getPushFlag() {
        return pushFlag;
    }

    private static Map<Integer, LoginEnum> map = EnumUtil.getEnumMap(values(), LoginEnum::getAccountType);
    private static Map<String, LoginEnum> codeMap = EnumUtil.getEnumMap(values(), LoginEnum::getCode);

    public static LoginEnum getByAccountType(Integer accountType) {
        return map.get(accountType);
    }

    public static LoginEnum getByCode(String code) {
        return codeMap.get(code);
    }
}
